﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DB_NH.DB_Map.SimpleFlow
{
    using NHibernate;
    using NHibernate.Mapping.ByCode;
    using NHibernate.Mapping.ByCode.Conformist;

    using DB_NH.DB_Model.SimpleFlow;

    public class MapForsfRecord : EntityMapping<sfRecord>
    {
        public MapForsfRecord()
        {
            Property(x => x.Content, map =>
            {
                map.Length(5000000);
            }); 
            
            Property(x => x.SourceId, map =>
            {
                map.Length(40);
            });

            Property(x => x.Status, map =>
            {
            });

            Property(x => x.Title, map =>
            {
                map.Length(500);
            });

            ManyToOne(x => x.sqUser, map =>
            {
                map.Column("SqUserID");
            });

            ManyToOne(x => x.Type, map =>
            {
                map.Column("TypeID");
            });

            Bag(x => x.Nodes, map =>
            {
                map.Key(keyMapper => keyMapper.Column("RecordID"));
            }, rel => rel.OneToMany());

            Bag(x => x.ToDos, map =>
            {
                map.Key(keyMapper => keyMapper.Column("RecordID"));
            }, rel => rel.OneToMany());
        }
    }
}
